import java.util.Scanner;

public class Test4 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = String.valueOf((int) (Math.random() * 9000) + 1000);
        System.out.println(str);
        System.out.println("输入四位密码");
        int i = 0;
        for (i = 0; i < 3; i++) {
            String password = in.nextLine();
            if (password.equals(str)) {
                System.out.println("登陆成功");
                System.exit(0);
            } else {
                System.out.println("密码错误,请重新输入");
            }
        }
        System.out.println("退出程序");
        System.exit(-1);
    }
}
